home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir42 / c7105.zip / BROWSE.CLA < prev    next >
Text File  |  1994-03-02  |  42KB  |  623 lines

  1.                  PROGRAM
  2. OMIT('┘')
  3. ┌───────────────────────────────────────────────────────────┬────────────────┐
  4. │                                                           │Version:3007.200│
  5. ├───────────────────────────────────────────────────────────┴────────────────┤
  6. │        BROWSE.CLA - The Browse Support Module                              │
  7. │                                                                            │
  8. │        The Browse Support Module manages the process of scrolling records  │
  9. │        through a list box.  Browse support is conducted in a session that  │
  10. │        is initiated by the BeginBrowse procedure and terminated by the     │
  11. │        EndBrowse procedure.  Multiple browse sessions may be conducted at  │
  12. │        the same time (e.g. a browse procedure calls a form which calls a   │
  13. │        lookup procedure).  The current status of a browse session is       │
  14. │        stored in a Session queue.  The browse process uses a position      │
  15. │        queue which contains a POSITION() string used to access displayed   │
  16. │        records.                                                            │
  17. │                                                                            │
  18. │        BeginBrowse(List,Locator,Immediate,Increment,Nomemo)                │
  19. │                                                                            │
  20. │            Initiate a browse session and append a new element to the       │
  21. │            Session queue.  Fixed (non-scrolling) queue elements should be  │
  22. │            the only elements in the list queue when a session begins.      │
  23. │                                                                            │
  24. │            "List" is the field number of a list box that displays a queue  │
  25. │            of formatted records.                                           │
  26. │                                                                            │
  27. │            "Locator" is an optional parameter that contains the field      │
  28. │            number of a locator field.  Typing any displayable character    │
  29. │            activates the locator field.  The USE variable of the locator   │
  30. │            field must be a key component, so completing the locator field  │
  31. │            scrolls the list box to the first matching record.              │
  32. │                                                                            │
  33. │            "Immediate" is an optional parameter that contains a 1 if the   │
  34. │            selected record is to be accessed each time the selector bar    │
  35. │            moves over a new record.                                        │
  36. │                                                                            │
  37. │            "Increment" is an optional parameter that contains a 1, 2, 3,   │
  38. │            or 4 to request an incremental locator field that automatically │
  39. │            locates a matching record after a pause in typing.  Increment   │
  40. │            values of 2, 3, and 4 request upper case, lower case, and       │
  41. │            capitalized locator fields.  An increment value of 1 uses the   │
  42. │            case entered by the operator.                                   │
  43. │                                                                            │
  44. │            "Nomemo" is an optional parameter that contains a 1 or 2 to     │
  45. │            disarm memo fields.  A value of 1 means that memos are not      │
  46. │            displayed in the list box.  A value of 2 means, in addition,    │
  47. │            that memos are not used as hot fields.  Memos are always        │
  48. │            retrieved for "Process Field" actions.                          │
  49. │                                                                            │
  50. │        BrowseAction(File,Key,Queue)                                        │
  51. │                                                                            │
  52. │            Manages the behavior of the list box, locator field, and hot    │
  53. │            fields.                                                         │
  54. │                                                                            │
  55. │            "File" is the FILE to be scrolled.                              │
  56. │                                                                            │
  57. │            "Key" is KEY to be used to access the file.                     │
  58. │                                                                            │
  59. │            "Queue" is the display queue, declared by the caller and used   │
  60. │            as the parameter of the FROM attribute of the list box.         │
  61. │                                                                            │
  62. │            BrowseAction returns a code requesting one of the following     │
  63. │            actions: the following actions:                                 │
  64. │                                                                            │
  65. │              Set the first record and set the last record of a limited     │
  66. │              range of consecutive records.                                 │
  67. │                                                                            │
  68. │              Reject a record by issueing GET(File,0) to dereference the    │
  69. │              record or indicate that a record is out of range by issueing  │
  70. │              NEXT(File) or PREVIOUS(File) to move the record position.     │
  71. │                                                                            │
  72. │              Format a display queue element for the current record.  The   │
  73. │              queue element will be placed in the display queue by the      │
  74. │              browse manager.                                               │
  75. │                                                                            │
  76. │              Process the record under the selector bar                     │
  77. │                                                                            │
  78. │              Process a field or key that the browse manager does not       │
  79. │              recognize.  The selected record has been accessed from the    │
  80. │              file and display queue.                                       │
  81. │                                                                            │
  82. │              Take action if there are no records to display.               │
  83. │                                                                            │
  84. │              Clear the key fields subordinate to the locator field.        │
  85. │                                                                            │
  86. │        EndBrowse                                                           │
  87. │                                                                            │
  88. │            Terminate the browse session.  Free position elements for this  │
  89. │            session from the Position queue.  Free the last element from    │
  90. │            the Session queue.                                              │
  91. │                                                                            │
  92. └────────────────────────────────────────────────────────────────────────────┘
  93.                  INCLUDE('KEYCODES.EQU')
  94.                  MAP
  95.                    BeginBrowse(SHORT,<SHORT>,<BYTE>,<BYTE>,<BYTE>)
  96.                    BrowseAction(FILE,KEY,QUEUE),BYTE
  97.                    EndBrowse
  98.                  END
  99.  
  100. Session          QUEUE                           !Browse session queue
  101. Action             BYTE                          ! Caller action
  102. Process            BYTE                          ! Internal process
  103. List               SHORT                         ! List field number
  104. Locator            SHORT                         ! Locator field number
  105. Immediate          BYTE                          ! Immediate processing flag
  106. Increment          BYTE                          ! Incremental locator flag
  107. Nomemo             BYTE                          ! No memo retrieval flag
  108. Location           STRING(40)                    ! Locator field contents
  109. Length             BYTE                          ! Locator contents length
  110. Count              BYTE                          ! List item count
  111. Fixed              BYTE                          ! Fixed list item count
  112. Item               BYTE                          ! Current item (1 to Count)
  113. Choice             BYTE                          ! Selector bar position
  114. LastChoice         BYTE                          ! Last Selector position
  115. Page               STRING(1)                     ! Current page (F,L,N,blank)
  116. FirstPage          BYTE                          ! First page request flag
  117. Base               SHORT                         ! Base for position queue
  118. Selected           STRING(256)                   ! Selected record position
  119.                  END
  120.  
  121. Position         QUEUE                           !Record position queue
  122.                    STRING(256)                   ! Record Position
  123.                  END
  124.                                                  !Caller actions
  125. NoAction         EQUATE(0)                       ! No caller action
  126. FormatQueue      EQUATE(1)                       ! Format the display queue
  127. ProcessField     EQUATE(2)                       ! Process another field
  128. NoRecords        EQUATE(3)                       ! No records to display
  129. FilterRecord     EQUATE(4)                       ! Filter a record
  130. ResetFirst       EQUATE(5)                       ! Set to first of a range
  131. ResetLast        EQUATE(6)                       ! Set to last of a range
  132. ProcessSelected  EQUATE(7)                       ! Process selected record
  133. ClearRestOfKey   EQUATE(8)                       ! Clear low fields of key
  134.  
  135.                                                  !Internal processes
  136. InitSession      EQUATE(1)                       ! Initialize browse session
  137. ProcessForward   EQUATE(2)                       ! Process records forward
  138. ProcessBackward  EQUATE(3)                       ! Process records backward
  139. ProcessSingle    EQUATE(4)                       ! Process a single record
  140. AcceptInput      EQUATE(5)                       ! Accept keyboard input
  141.  
  142. LoChar           EQUATE(32)                      !Lowest displayable char
  143. HiChar           EQUATE(127)                     !Highest displayable char
  144.  
  145.                  CODE                            !Dummy program
  146.  
  147. BeginBrowse      PROCEDURE(InList,InLocator,InImmediate,InIncrement,InNomemo)
  148.  
  149.   CODE
  150.   IF RECORDS(Session) THEN PUT(Session).         !Save any current session
  151.   CLEAR(Session)                                 !Clear the session record
  152.   Action = NoAction                              !Set no caller action
  153.   Process = InitSession                          !Initialize a browse session
  154.   List = InList                                  !Set list field number
  155.   Locator = InLocator                            !Set locator field number
  156.   Immediate = InImmediate                        !Set immediate process flag
  157.   IF Locator THEN Increment = InIncrement.       !If there is a locator field
  158.   Nomemo = InNomemo                              !Set no memo flag
  159.   Count = ROWS(List)                             !Set item count
  160.   Choice = 1                                     !Set top choice
  161.   LastChoice = 1                                 !Set top last choice
  162.   Base = RECORDS(Position)                       !Set base position
  163.   ADD(Session,RECORDS(Session)+1)                !Add the session record
  164.   RETURN                                         !Return to caller
  165.  
  166. BrowseAction     FUNCTION(File,Key,Queue)
  167.  
  168. Delay            EQUATE(50)                      !Time delay (1/2 second)
  169. SpaceKey         EQUATE(32)                      !Space bar keycode
  170. TimeOut          LONG                            !Deadline time (.01 seconds)
  171. LocatorContents  STRING(255)                     !Locator field contents
  172.  
  173.   CODE
  174.   CASE Action                                    !Process caller's action
  175.   OF FilterRecord                                !Caller filtered the record
  176.     CASE POSITION(Key)                           ! Check callers action
  177.     OF ''                                        ! The record is rejected
  178.       IF Process = ProcessSingle                 !  And previously accepted
  179.         DELETE(Queue)                            !   Delete the queue element
  180.         GET(Position,Base+Choice-Fixed)          !   Get the position element
  181.         DELETE(Position)                         !   And delete it
  182.         Process = ProcessForward                 !   Display a new last
  183.         Item = RECORDS(Queue) + 1                !    record forward
  184.         GET(Position,RECORDS(Position))          !   Get last display record
  185.         RESET(Key,Position)                      !   Reset to last display
  186.         NEXT(File)                               !   Retrieve last record
  187.       END                                        !  End IF
  188.     OF Position                                  ! The record is accepted
  189.       Action = FormatQueue                       !  Ask caller to format
  190.       RETURN(Action)                             !  Return to caller
  191.     ELSE                                         ! The record is out of range
  192.       DISPLAY(List)                              !  Display the page
  193.       SELECT(List,Choice)                        !  Select the list box
  194.       Selected = ''                              !  Clear selected position
  195.       Process = AcceptInput                      !  Get keyboard input
  196.     END                                          ! End CASE
  197.  
  198.   OF FormatQueue                                 !Caller formatted the queue
  199.     CASE Process                                 ! Jump to current process
  200.     OF ProcessForward                            ! On forward processing
  201.       ADD(Queue,RECORDS(Queue)+1)                !  Add new last element
  202.       ADD(Position,RECORDS(Position)+1)          !  Add new last position
  203.       IF RECORDS(Queue) > Count                  !  If the page overflows
  204.         GET(Queue,Fixed+1)                       !   Get the first element
  205.         DELETE(Queue)                            !   And delete it
  206.         GET(Position,Base+1)                     !   Get the first position
  207.         DELETE(Position)                         !   And delete it
  208.       END                                        !  End IF
  209.       Item += 1                                  !  Increment current item
  210.     OF ProcessBackward                           ! On backward processing
  211.       ADD(Queue,Fixed+1)                         !  Add new first element
  212.       ADD(Position,Base+1)                       !  Add new first position
  213.       IF RECORDS(Queue) > Count                  !  If the page overflows
  214.         GET(Queue,RECORDS(Queue))                !   Get the last element
  215.         DELETE(Queue)                            !   And delete it
  216.         GET(Position,RECORDS(Position))          !   GET the last position
  217.         DELETE(Position)                         !   And delete it
  218.       END                                        !  End IF
  219.       Item -= 1                                  !  Decrement current item
  220.       IF Page = 'N' THEN Choice += 1.            ! Increment selector bar
  221.     OF ProcessSingle                             ! On a single record
  222.       PUT(Queue)                                 !  Replace the element
  223.       DISPLAY(List)                              !  Display the page
  224.       SELECT(List,Choice)                        !  Select the list box
  225.       Process = AcceptInput                      !  Get keyboard input
  226.       Selected = ''                              !  Clear selected position
  227.     END                                          ! End CASE
  228.  
  229.   OF ProcessSelected                             !Caller processed a record
  230.     Selected = POSITION(Key)                     ! Set selected position
  231.  
  232.   OF ProcessField                                ! Caller processed a field
  233.     IF Process = InitSession                     ! If we got here from Init code
  234.       Process = AcceptInput                      !  Skip internal field handling
  235.       Action = NoAction                          !  Clear ACTION
  236.       RETURN(Action)                             !  And go another time around
  237.     END                                          ! END (If we got here...)
  238.     IF FIELD() <> Locator                        ! For non-locator field
  239.       IF Increment                               !  If incremental locator
  240.         DO ClearLocator                          !   Clear locator
  241.       END                                        !  End IF
  242.       IF INRANGE(FIELD(),1,List-1)               !  From a prior field
  243.         FirstPage = 1                            !   Request the first page
  244.       END                                        !  End IF
  245.     END                                          ! End IF
  246.     IF SELECTED() = List                         ! If list field is selected
  247.       IF FirstPage                               !  If first page is requested
  248.         DO FirstPage                             !   Display the first page
  249.         Action = ResetFirst                      !   Ask caller to first
  250.         RETURN(Action)                           !    record in range
  251.       ELSIF FIELD() <> Locator                   !  From any but the locator
  252.         CASE POSITION(Key)                       !   Check the record
  253.         OF ''                                    !   If record was dereferenced
  254.           DO GetChoice                           !    Get selected record
  255.           IF POSITION(Key) = Position            !    If record is still there
  256.             Process = ProcessSingle              !     Display one record
  257.             Action = FilterRecord                !     Ask caller to filter
  258.             RETURN(Action)                       !     Return to caller
  259.           ELSE                                   !    If record was deleted
  260.             DELETE(Queue)                        !     Delete the element
  261.             DELETE(Position)                     !     Delete its position
  262.             IF RECORDS(Queue) = Fixed            !     If queue is now empty
  263.               DO LastPage                        !      Display the last page
  264.               Action = ResetLast                 !      Ask caller to reset to
  265.               RETURN(Action)                     !       last record in range
  266.             ELSE                                 !     Otherwise
  267.               Process = ProcessForward           !      Display a new
  268.               Item = RECORDS(Queue) + 1          !       last record
  269.               GET(Position,RECORDS(Position))    !      Reset to the bottom
  270.               RESET(Key,Position)                !       record displayed
  271.               NEXT(File)                         !      Read the record
  272.             END                                  !     End IF
  273.           END                                    !    End IF
  274.         OF Position                              !   If record didn't move
  275.           GET(Queue,Choice)                      !    Get display element
  276.           Action = FilterRecord                  !    Ask caller to
  277.           Process = ProcessSingle                !     filter one record
  278.           RETURN(Action)                         !    Return to caller
  279.         ELSE                                     !   If record moved
  280.           DO NewPage                             !    Display the new page
  281.         END                                      !   End CASE
  282.       END                                        !  End IF
  283.     ELSE                                         ! Else another field selected
  284.       IF FIELD() <> SELECTED()                   !  If selecting a new field
  285.         Process = AcceptInput                    !    Accept keyboard input
  286.       END                                        !  End IF
  287.     END                                          ! End IF
  288.  
  289.   OF NoRecords                                   !Caller added a record
  290.     IF SELECTED() = List                         ! And selected the list field
  291.       DO FirstPage                               !  Display the first page
  292.       Action = ResetFirst                        !  Ask caller to reset to
  293.       RETURN(Action)                             !   first record in range
  294.     END                                          ! End IF
  295.  
  296.   OF ClearRestOfKey                              !Caller cleared subfields
  297.     SELECT(Locator)                              !  Select the locator field
  298.     Process = AcceptInput                        !  Accept keyboard input
  299.   END                                            !End CASE
  300.  
  301.   LOOP                                           !Main processing loop
  302.     CASE Process                                 !Jump to current process
  303.     OF InitSession                               !Start browse session
  304.       Fixed = RECORDS(Queue)                     ! Set fixed list item count
  305.       IF List <> 1                               ! If the List is not first
  306.         Action = ProcessField                    !   Process any FIELD code
  307.         RETURN(Action)                           !   Do It!
  308.       ELSE
  309.         Process = AcceptInput                    ! Accept keyboard input
  310.       END                                        ! END (If the List...)
  311.     OF ProcessForward                            !Process records forward
  312.       IF Item <= Count                           ! If page is not full
  313.         IF Nomemo THEN NOMEMO(File).             !  Disarm unneeded memos
  314.         NEXT(File)                               !  Read the next record
  315.         IF ~ERRORCODE()                          !  If a record was found
  316.           Position = POSITION(Key)               !   Save its position
  317.           Action = FilterRecord                  !   Ask caller to filter
  318.           RETURN(Action)                         !   Return to caller
  319.         ELSE                                     !  If no record was found
  320.           IF INSTRING(Page,'FN',1,1)             !   If new page
  321.             Process = ProcessBackward            !    Display prior records
  322.             Item = Count - Item + Fixed + 1      !     from the top record
  323.             IF RECORDS(Position) > Base          !    For a partial screen
  324.               GET(Position,Base+1)               !     Get top position
  325.               RESET(Key,Position)                !     Reset to top record
  326.               PREVIOUS(File)                     !     Point to prior page
  327.               CYCLE                              !     Process backwards
  328.             ELSE                                 !    For a blank screen
  329.               SET(Key)                           !     Set to end of file
  330.               Action = ResetLast                 !     Ask caller to reset
  331.               RETURN(Action)                     !     Return to caller
  332.             END                                  !    End IF
  333.           END                                    !   End IF
  334.         END                                      !  End IF
  335.       END                                        ! End IF
  336.       DISPLAY(List)                              ! Display the page
  337.       SELECT(List,Choice)                        ! Select the list box
  338.       Selected = ''                              ! Clear selected position
  339.       Process = AcceptInput                      ! Get keyboard input
  340.  
  341.     OF ProcessBackward                           !Process records backward
  342.       IF Item >= Fixed + 1                       ! If page is not full
  343.         IF Nomemo THEN NOMEMO(File).             !  Disarm unneeded memos
  344.         PREVIOUS(File)                           !  Read the prior record
  345.         IF ~ERRORCODE()                          !  If a record was found
  346.           Position = POSITION(Key)               !   Save its position
  347.           Action = FilterRecord                  !   Ask caller to filter
  348.           RETURN(Action)                         !   Return to caller
  349.         END                                      !  End IF
  350.       END                                        ! If page is full
  351.       DISPLAY(List)                              !  Display the page
  352.       SELECT(List,Choice)                        !  Select the list box
  353.       Selected = ''                              !  Clear selected position
  354.       Process = AcceptInput                      !  Get keyboard input
  355.  
  356.     OF AcceptInput                               !Get keyboard input
  357.       IF SELECTED() = List                       ! If the list box is selected
  358.         IF RECORDS(Queue) = Fixed                !  If there are no records
  359.           CASE Page                              !   Jump to current page
  360.           OF 'F'                                 !   On the first page
  361.             GET(File,0)                          !    Clear the current record
  362.             Action = NoRecords                   !    Ask caller for records
  363.           OF 'N'                                 !   On a new page
  364.             DO LastPage                          !    Display the last page
  365.             Action = ResetLast                   !    Ask for last record
  366.           ELSE                                   !   On any other page
  367.             DO FirstPage                         !    Display the first page
  368.             Action = ResetFirst                  !    Ask for first record
  369.           END                                    !   End CASE
  370.           RETURN(Action)                         !   Return to caller
  371.         END                                      !  End IF
  372.  
  373.         IF Immediate                             ! For immediate processing
  374.           GET(Position,Base+CHOICE(List)-Fixed)  !  Get selected position
  375.           IF Selected <> Position                !  If selector moved
  376.             GET(Position,Base+Choice-Fixed)      !   Get selected position
  377.             RESET(Key,Position)                  !   Reset to that record
  378.             IF Nomemo = 2 THEN NOMEMO(File).     !   Disarm unneeded memos
  379.             NEXT(File)                           !   Read the record
  380.             IF Position = POSITION(Key)          !   If record is there
  381.               Action = ProcessSelected           !    Ask to process record
  382.               RETURN(Action)                     !    Return to caller
  383.             ELSE                                 !   Else
  384.               DO NewPage                         !    Rebuild the Queue
  385.               Action = ProcessField              !    Ask to process record
  386.               RETURN(Action)                     !    Return to caller
  387.             END                                  !   End IF
  388.           END                                    !  End IF
  389.         END                                      ! End IF
  390.         IF Locator                               ! If there is a locator field
  391.           ERASE(Locator)                         !  Erase locator contents
  392.           IF Increment                           !  For incremental locator
  393.             DO ShowLocator                       !   Show locator field
  394.           END                                    !  End IF
  395.         END                                      ! End IF
  396.         LastChoice = CHOICE(List)                ! Save selector position
  397.       END                                        !End IF
  398.       ACCEPT                                     !Enable the keyboard
  399.       CASE FIELD()                               !Jump to field edit routine
  400.  
  401.       OF Locator                                 !Process the locator field
  402.         IF CONTENTS(Locator)                     ! If locator is requested
  403.           IF Increment                           !  If incremental locator
  404.             Location = CONTENTS(Locator)         !   Save location
  405.             Length = LEN(CLIP(Location))         !   Save location length
  406.           END                                    !  End IF
  407.           SELECT(List)                           !  Select the list box
  408.           DO NewPage                             !  Display a new page
  409.           Action = ProcessField                  !  Ask caller to process
  410.           RETURN(Action)                         !  Return to caller
  411.         ELSE                                     ! ELSE (If No Locator)
  412.           Action = ProcessField                  !  Ask caller to process
  413.           RETURN(Action)                         !  Return to caller
  414.         END                                      ! End IF
  415.  
  416.       OF List                                    !Process the list field
  417.         Choice = CHOICE(List)                    ! Save selector bar position
  418.         IF SELECTED() <> List                    ! Process any new fields
  419.           IF SELECTED() <> Locator               !  IF not locating
  420.             DO GetChoice                         !   Get the highlighted record
  421.           END                                    !  END (IF not locating)
  422.           Action = ProcessField                  !  Ask caller to process
  423.           RETURN(Action)                         !  Return to caller
  424.         END                                      ! END (Process...)
  425.         CASE KEYCODE()                           ! Jump to key edit routine
  426.  
  427.         OF LoChar TO HiChar                      ! For any locator character
  428.         OROF BSKey OROF SpaceKey                 ! Or a backspace or space
  429.           IF Locator                             !  If there is a locator
  430.             IF Increment                         !   On incremental locator
  431.               DO GatherKeys                      !    Gather keystrokes
  432.               IF Location                        !    If not blank
  433.                 PRESS(SUB(Location,1,Length))    !     Press the string
  434.                 PRESS(DownKey)                   !     Complete the field
  435.                 SELECT(Locator)                  !     Select locator
  436.               END                                !    End IF
  437.             ELSE                                 !   On standard locator
  438.               PRESS(KEYCODE())                   !    Press in the keycode
  439.               SELECT(Locator)                    !    Select locator field
  440.             END                                  !   End IF
  441.             Action = ClearRestOfKey              !    Ask caller to clear
  442.             RETURN(Action)                       !     subordinate fields
  443.           END                                    !  End IF
  444.  
  445.         OF CtrlPgUp                              ! Process the Ctrl-PgUp key
  446.           DO FirstPage                           !  Display the first page
  447.           IF Increment                           !  If incremental locator
  448.             DO ClearLocator                      !   Clear locator field
  449.           END                                    !  End IF
  450.           Action = ResetFirst                    !  Ask caller to reset to
  451.           RETURN(Action)                         !   first record in range
  452.  
  453.         OF PgUpKey                               ! Process the PgUp key
  454.           IF LastChoice <> Fixed + 1             !  If not at the top
  455.             Choice = Fixed + 1                   !   Selector bar to top
  456.           ELSE                                   !  From the top
  457.             Page = ''                            !   Clear page flag
  458.             Process = ProcessBackward            !   Display a new page
  459.             Item = Count                         !    of records backward
  460.             GET(Position,Base+1)                 !   Reset to the top
  461.             RESET(Key,Position)                  !    record displayed
  462.             PREVIOUS(File)                       !   Point to prior record
  463.           END                                    !  End IF
  464.  
  465.         OF UpKey                                 ! Process the up arrow
  466.           IF LastChoice = Fixed + 1              !  From the top line
  467.             Page = ''                            !   Clear page flag
  468.             Process = ProcessBackward            !   Display a single
  469.             Item = Fixed + 1                     !    record backward
  470.             GET(Position,Base+1)                 !   Reset to the top
  471.             RESET(Key,Position)                  !    record displayed
  472.             PREVIOUS(File)                       !   Point to prior record
  473.           END                                    !  End IF
  474.  
  475.         OF DownKey                               ! Process the down arrow
  476.           IF LastChoice = Count                  !  From the bottom line
  477.             Page = ''                            !   Clear page flag
  478.             Process = ProcessForward             !   Display a single
  479.             Item = Count                         !    record forward
  480.             GET(Position,RECORDS(Position))      !   Reset to the bottom
  481.             RESET(Key,Position)                  !    record displayed
  482.             NEXT(File)                           !   Point to the next record
  483.           END                                    !  End IF
  484.  
  485.         OF PgDnKey                               ! Process the PgDn key
  486.           IF LastChoice <> Count                 !  If not at the bottom
  487.             Choice = Count                       !   Selector bar to bottom
  488.           ELSE                                   !  From the bottom
  489.             Page = ''                            !   Clear page flag
  490.             Process = ProcessForward             !   Display a new page
  491.             Item = 1 + Fixed                     !    of records forwards
  492.             GET(Position,RECORDS(Position))      !   Reset to the bottom
  493.             RESET(Key,Position)                  !    record displayed
  494.             NEXT(File)                           !   Point to the next record
  495.           END                                    !  End IF
  496.  
  497.         OF CtrlPgDn                              ! Process the Ctrl-PgDn Key
  498.           DO LastPage                            !  Display the last page
  499.           IF Increment                           !  If incremental locator
  500.             DO ClearLocator                      !   Clear locator field
  501.           END                                    !  End IF
  502.           Action = ResetLast                     !  Ask caller to reset to
  503.           RETURN(Action)                         !   last record in range
  504.  
  505.         OF   LeftKey                             ! For left arrow key,
  506.         OROF Rightkey                            ! Or right arrow key,
  507.         OROF Homekey                             ! Or Home key,
  508.         OROF Endkey                              ! Or End key,
  509.         OROF MouseLeft                           ! Or a mouse click
  510.                                                  !  Don't do anything
  511.         ELSE                                     ! For any other key
  512.           DO GetChoice                           !  Get selected record
  513.           Action = ProcessField                  !  Ask caller to process
  514.           RETURN(Action)                         !  Return to caller
  515.  
  516.         END                                      ! End CASE KEYCODE()
  517.         IF Increment                             ! If incremental locator
  518.           DO ClearLocator                        !  Clear locator field
  519.         END                                      ! End
  520.       ELSE                                       ! Process any other field
  521.         IF FIELD() >= List OR FIELD() < 0        !  If not list or setup fld
  522.           DO GetChoice                           !   Get selected record
  523.         ELSIF SELECTED() = List and ~FIELD()     ! Else if reprocessing List
  524.           DO GetChoice                           !   Get selected record
  525.         END                                      !  End IF
  526.         Action = ProcessField                    !  Ask caller to process
  527.         RETURN(Action)                           !  Return to caller
  528.       END                                        ! End CASE FIELD()
  529.     END                                          !End CASE BrowseProcess
  530.   END                                            !End LOOP
  531.  
  532. GetChoice ROUTINE                                !Get selected record
  533.   GET(Queue,Choice)                              ! Get selected element
  534.   GET(Position,Base+Choice-Fixed)                ! Get selected position
  535.   RESET(Key,Position)                            ! Reset to that record
  536.   NEXT(File)                                     ! Read the record
  537.  
  538. FirstPage ROUTINE                                !Display first page
  539.   FirstPage = 0                                  ! Clear first page request
  540.   Page = 'F'                                     ! Set first page flag
  541.   DO DeletePage                                  ! Delete the old page
  542.   Choice = Fixed + 1                             ! Reset selector bar
  543.   Process = ProcessForward                       ! Display a new page
  544.   Item = Fixed + 1                               !  of records forward
  545.   SET(Key)                                       ! Set to the first record
  546.  
  547. LastPage ROUTINE                                 !Display last page
  548.   Page = 'L'                                     ! Set last page flag
  549.   DO DeletePage                                  ! Delete the old page
  550.   Choice = Count                                 ! Reset selector bar
  551.   Process = ProcessBackward                      ! Display a new page
  552.   Item = Count                                   !  of records backward
  553.   SET(Key)                                       ! Set to the last record
  554.  
  555. NewPage ROUTINE                                  !Display a new page
  556.   Page = 'N'                                     ! Set new page flag
  557.   DO DeletePage                                  ! Delete the old page
  558.   SET(Key,Key)                                   ! Set to the new record
  559.   Choice = Fixed + 1                             ! Selector bar to top
  560.   Process = ProcessForward                       ! Display a new page
  561.   Item = Fixed + 1                               !  of records forward
  562.  
  563. DeletePage ROUTINE                               !Delete the current page
  564.   LOOP WHILE RECORDS(Queue) > Fixed              ! Delete all queue
  565.     GET(Queue,RECORDS(Queue))                    !  elements after the
  566.     DELETE(Queue)                                !   fixed elements
  567.   END                                            ! End LOOP
  568.   LOOP WHILE RECORDS(Position) > Base            ! Delete all position
  569.     GET(Position,RECORDS(Position))              !  elements after the
  570.     DELETE(Position)                             !   base position
  571.   END                                            ! End LOOP
  572.  
  573. GatherKeys ROUTINE                               !Gather locator keystrokes
  574.   DO AppendKey                                   ! Append pending keystroke
  575.   TimeOut = CLOCK() + Delay                      ! Set the time delay
  576.   LOOP UNTIL CLOCK() > TimeOut                   ! Loop until time out
  577.     IF KEYBOARD()                                !  If there is a keystroke
  578.       ASK                                        !   Read the keystroke
  579.       DO AppendKey                               !   Append the keystroke
  580.       DO ShowLocator                             !   Show the user
  581.       TimeOut = CLOCK() + Delay                  !   Reset the time delay
  582.     END                                          !  End IF
  583.   END                                            ! End LOOP
  584.  
  585. AppendKey ROUTINE                                !Append keystroke to locator
  586.   CASE KEYCODE()                                 ! Process the keystroke
  587.   OF LoChar TO HiChar OROF SpaceKey              ! For a character
  588.     IF Length < COLS(Locator)                    !  If it will fit
  589.       Location = SUB(Location,1,Length) & CHR(KEYCODE()) ! Add it on
  590.       Length += 1                                !  Increment the length
  591.     END                                          !  End IF
  592.   OF BSKey                                       ! For a backspace
  593.     IF Length > 0 THEN Length -= 1.              !  Decrement the length
  594.     Location = SUB(Location,1,Length)            !  Shorten the string
  595.     EXECUTE Increment - 1                        !  For locator case
  596.       Location = UPPER(Location)                 !   Upper case location
  597.       Location = LOWER(Location)                 !   Lower case location
  598.       Location = UPPER(SUB(Location,1,1)) |      !   Capitalize location
  599.                & LOWER(SUB(Location,2,SIZE(Location)-1))
  600.     END                                          !  End EXECUTE
  601.   END                                            ! End CASE
  602.  
  603. ClearLocator ROUTINE                             !Clear locator field
  604.   Location = ''                                  ! Clear field string
  605.   Length = 0                                     ! Zero field length
  606.   DO ShowLocator                                 ! Show locator field
  607.  
  608. ShowLocator ROUTINE                              !Show locator field contents
  609.   SHOW(ROW(Locator),COL(Locator),SUB(Location,1,COLS(Locator)))
  610.  
  611. EndBrowse        PROCEDURE
  612.  
  613.   CODE
  614.   LOOP WHILE RECORDS(Position) > Base            !Delete all position
  615.     GET(Position,RECORDS(Position))              ! elements after the
  616.     DELETE(Position)                             !  base position
  617.   END                                            !End LOOP
  618.   DELETE(Session)                                !Delete the current session
  619.   IF RECORDS(Session)                            !For any prior session
  620.     GET(Session,RECORDS(Session))                ! Get the session element
  621.   END                                            !End IF
  622.   RETURN                                         !Return to caller
  623.